import {createRouter, createWebHashHistory} from "vue-router";
import Cmp01Engine from "../components/Cmp01Engine.vue";
import Cmp02Shell from "../components/Cmp02Shell.vue";
import cmp03Checkout from "../components/Cmp03Checkout.vue";
import carStore from "../config/store.js"

let router = createRouter({
    history: createWebHashHistory(),
    routes: [
        {
            path: "/",
            component: Cmp01Engine
        },
        {
            path: "/shell",
            component: Cmp02Shell
        },
        {
            path: "/checkout",
            component: cmp03Checkout
        }
    ]

});

// 在钩子函数外部创建 Store 对象
let car = carStore();

router.beforeEach((to, from, next) => {

    // 在路由守卫中也想获取 Pinia 中的共享数据
    console.log(car)

    next();
})

export default router;